package org.terrier.matching.models.basicmodel;

import org.terrier.matching.models.Idf;
import org.terrier.utility.ApplicationSetup;

public class WBpdf extends BasicModel {
	/*
     * Weibull pdf 
     */
    double wa = Double.parseDouble(ApplicationSetup.getProperty("distribution.parameter.0", "1.1d"));
    double wb = Double.parseDouble(ApplicationSetup.getProperty("distribution.parameter.1", "0.5d"));
    

	@Override
	public String getInfo() {
		return "WBpdf"+wa+"_"+wb;
	}

	@Override
	public double score(double tf, double documentFrequency,
			double termFrequency, double keyFrequency, double documentLength) {
		return -Idf.log((wb/tf) * Math.pow((tf / wa),wb) * Math.exp(-Math.pow((tf / wa),wb)))*keyFrequency;
		// return -Idf.log(Math.exp(-Math.pow((tf / wa),wb)));
	}
	
	public void initModel(){
		String value = null;
		if ((value = ApplicationSetup.getProperty("distribution.parameter.0", "1.1d"))!=null){
			this.wa = Double.parseDouble(value);
		}
		if ((value = ApplicationSetup.getProperty("distribution.parameter.1", "0.5d"))!=null){
			this.wb = Double.parseDouble(value);
		}
	}

}
